/*
 * Improbability Drive
 * Phillip Cardon, Thach Nguyen, Cristopher Claeys
 * 4/26/2011
 */

package testers;

import java.net.MalformedURLException;
import java.net.URL;

import buffers.SynchronizedBuffer;

public class AddUrls extends Thread {
	SynchronizedBuffer<URL> pb;
	public AddUrls (SynchronizedBuffer<URL> buffer) {
		pb = buffer;
	}
	
	private URL makeUrl() {
		String w = "http://www.";
		String c = ".com/";
		String a = RandomString.randomstring();
		URL u = null;
		try {
			u = new URL(w + a + c);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
		}
		return u;
	}
	
	public void run() {
		while(true) {
			URL u = makeUrl();
			if (u != null) {
				pb.enqueue(u);
				System.out.println("Added url: " + u);
			}
		}
	}
}
